# import cv2
# from django.http import StreamingHttpResponse
# import numpy as np
#
#
# # 获取连接好的摄像头
# def detect_cameras():
#     # 获取连接的摄像头列表
#     cameras = []
#     for i in range(10):  # 假设最多有10个摄像头
#         cap = cv2.VideoCapture(i)
#         if cap.isOpened():
#             cameras.append(i)
#             cap.release()
#
#     return cameras
#
#
# # 获取摄像头数据流
# def video_feed(cameras):
#     # 捕获多个摄像头画面
#     caps = [cv2.VideoCapture(cam) for cam in cameras]
#
#     def frame_generator():
#         while True:
#             for cap in caps:
#                 ret, frame = cap.read()
#                 if not ret:
#                     break
#
#                 # 将图像转换为JPEG格式
#                 _, buffer = cv2.imencode('.jpg', frame)
#                 frame_bytes = buffer.tobytes()
#
#                 yield (b'--frame\r\n'
#                        b'Content-Type: image/jpeg\r\n\r\n' + frame_bytes + b'\r\n')
#
#     return StreamingHttpResponse(frame_generator(), content_type='multipart/x-mixed-replace; boundary=frame')
#
#
# if __name__ == '__main__':
#     cameras = detect_cameras()
#     print(cameras)
